using AndroidCaller;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class LevelGUI : MonoBehaviour
{
	public Button[] buttons;

	public int number_of_scenes;

	public GameObject arrow_left;

	public GameObject arrow_right;

	public Sprite sprite_locked_button;

	public Sprite sprite_unlocked_button;

	private int counter;
    private MyAdManager adManage;

    private void Start()
	{
		Time.timeScale = 1f;
		AudioListener.pause = false;
		arrow_left.SetActive(value: false);
        ShowSet(0);
        adManage = new MyAdManager();
    }

	private void ShowSet(int start)
	{
		int num = 0;
		int num2 = start;
		Button[] array = buttons;
		foreach (Button button in array)
		{
			num2++;
			button.GetComponentInChildren<Text>().text = num2 + string.Empty;
			if (start > PlayerPrefs.GetInt("level_current_reach", 0))
			{
				button.GetComponentInChildren<Image>().sprite = sprite_locked_button;
			}
			else
			{
				button.GetComponentInChildren<Image>().sprite = sprite_unlocked_button;
			}
			start++;
			num++;
		}
	}

	private void RefreshGUI()
	{
		if (counter <= 0)
		{
			counter = 0;
			arrow_left.SetActive(value: false);
			arrow_right.SetActive(value: true);
			ShowSet(0);
		}
		else if (counter > 0 && counter < number_of_scenes - 1)
		{
			arrow_left.SetActive(value: true);
			arrow_right.SetActive(value: true);
			ShowSet(counter * buttons.Length);
		}
		else
		{
			counter = number_of_scenes - 1;
			arrow_left.SetActive(value: true);
			arrow_right.SetActive(value: false);
			ShowSet(counter * buttons.Length);
		}
	}

	public void ArrowLeftClick()
	{
		counter--;
		RefreshGUI();
	}

	public void ArrowRightClick()
	{
		counter++;
		RefreshGUI();
	}

	public void LevelClick(Button button)
	{
		int result = 0;
		int.TryParse(button.GetComponentInChildren<Text>().text, out result);
		result--;
		if (result <= PlayerPrefs.GetInt("level_current_reach", 0))
		{
			PlayerPrefs.SetInt("selected_level", result);
			//NativeCall.Call("levelsclosed");
			LoadingPanel.GetInstance().Show();
			SceneManager.LoadScene("Scene");
            adManage.MyShowNative();
		}
	}
}
